import request from '@/utils/request';

export async function getProduceInfoByPage(params: any) {
  return request('/api/project/getProductInfoByPage', {
    method: 'POST',
    data: params,
  });
}

//获取类型和编号
export async function getStandProductCode(params: any) {
  return request('/api/design/getStandProductAndType', {
    method: 'POST',
  });
}

//发布单条
export async function releaseProductInfo(params: any) {
  return request('/api/project/releaseProductInfos', {
    method: 'POST',
    data: params,
  });
}

export async function getProduceType(params: any) {
  return request('/api/project/getProduceType', {
    method: 'POST',
  });
}

export async function addProduceInfo(params: any) {
  return request('/api/project/addProductInfos', {
    method: 'POST',
    data: params,
  });
}

export async function updateProduceInfo(params: any) {
  console.log(params);
  return request('/api/project/updateProductInfo', {
    method: 'POST',
    data: params,
  });
}

export async function delProduceInfo(params: any) {
  return request('/api/project/delProductInfo', {
    method: 'POST',
    data: params,
  });
}

export async function exportProduceInfo(params: any) {
  return request('/api/project/exportProduceInfo', {
    method: 'POST',
    data: params,
    responseType: 'blob',
  });
}

// 获取工程师
export async function getProjectTeamEngineers(para: any) {
  return request('/api/project/getProjectTeamEngineers', {
    method: 'POST',
    params: {
      infoId: para,
    },
  });
}

//批量导入柜体数据
export async function addProductInfosByExcel(para: any) {
  return request('/api/project/addProductInfosByExcel',{
      method: 'POST',
      requestType: 'form',
      data: para.file,
      params: {
        infoId: para.infoId,
      },
  })
}

//下载模板
export async function downloadExcelTemplate() {
  return request('/api/project/downloadExcelTemplate',{
      method: 'GET',
      responseType: 'blob',
  })
}

export default {
  getProduceInfoByPage,
  addProduceInfo,
  updateProduceInfo,
  delProduceInfo,
  exportProduceInfo,
  getStandProductCode,
};
